package myTest;

public class test{
	public static void main(String[] args){
		int a = -34%5;
		int b = 78%(-4);
		int c = -34%(-5);
		int d = 5%1;
		System.out.println(a);
		System.out.println(b);
		System.out.println(c);
		System.out.println(d);
		System.out.println("************");
		
		System.out.println(Byte.SIZE);
		System.out.println(Short.SIZE);
		System.out.println(Integer.SIZE);
		System.out.println(Float.SIZE);
		System.out.println(Long.SIZE);
		System.out.println(Double.SIZE);
		System.out.println("************");
		
		float f = 12.5F;
		int i = (int)f;
		System.out.println(f+","+i);
		System.out.println("************");
		
		System.out.println('1'+0);
		System.out.println((char)0x40);
		System.out.println('\u0061');
		char g = 90;
		System.out.println(g);
		System.out.println("1"+(1+1)+1);
		System.out.println(1+"Welcome"+('\u0001'+1));
		System.out.println(1+"Welcome"+'a'+1);
		System.out.println("************");
		
		long time = System.currentTimeMillis()/1000;
		System.out.println("second: "+time%60);
		System.out.println("minute: "+(time/60)%60);
		System.out.println("hour: "+(int)((time/60)/60)%24);
		System.out.println("************");
		
		int x = 1;
		System.out.println((x != 1) == !(x == 1));
		System.out.println((x==1)|(x++ > 1));
		System.out.println(x);
		System.out.println("************");
		
		char chx = 'a';
		char chy = 'c';
		System.out.println(++chy);
		System.out.println(chy++);
		System.out.println(chx>chy);
		System.out.println(chx-chy);
		System.out.println("************");
		
		x=3;
		int y=3;
		switch (x+3){
		case 6: y=1;
		default: y += 1;
		}
		System.out.println(y);
		
		a=1;
		switch(a){
		case 1: x+=5; break;
		case 2: x+=10;
		}
		System.out.println(x);
		System.out.println("************");
		
		System.out.printf("%4d\n", 72);
		System.out.printf("%f %e\n", 32.32, 32.32);
		System.out.printf("%5.4f %5.4e\n", 32.32, 32.32);
		System.out.printf("%7b\n", (1>2));
		System.out.printf("%8s\n", "Java");
		System.out.printf("%-8b%s\n", (1>2), "Java");
		String str = "%"+"123456".length()+"b%-1s\n";
		System.out.printf(str, (1>2), "Java");
		System.out.println("************");
		
		i = 0;
		System.out.println(--i + i + i++);
		System.out.println(i + ++i);
		i = 0;
		i = i + (i=1);
		System.out.println(i);
		i = 0;
		i = (i=1) + i;
		System.out.println(i);
		a = 1;
		a += a + (a=3);
		System.out.println(a);
		double n=1.0;
		n -= 1.5*3 + (n++);
		System.out.println(n);
		System.out.println("************");
		
		int sum=0;
		for(i=0; i<10; ++i)
			sum += i;
		System.out.println(sum);
		System.out.println("************");
		
		outer:
		for(i=1; i<10; i++)
			for(int j=1; j<10; j++){
				if(i*j>50)
					break outer;
				System.out.println(i*j);
			}
		
		int arrayx=30;
		int[] numbers = new int[arrayx];
		arrayx=60;
		System.out.println("arrayx is "+arrayx);
		System.out.println("The size of numbers is "+numbers.length);
		
		double[] r = new double[100];
		for(i=0; i<r.length; i++)
			r[i] = Math.random()*100;
		for(i=0; i<r.length; i++)
			System.out.print(r[i]+",");
		System.out.println();
		double[] t = new double[5];
		System.arraycopy(r, 1, t, 0, t.length);
		for(i=0; i<t.length; i++)
			System.out.print(t[i]+",");
		System.out.println("*************");
		
		int number=0;
		numbers = new int[1];
		m(number,numbers);
		System.out.println("number="+number+"; numbers[0]="+numbers[0]);
		int[] list = {1, 2, 3, 4, 5};
		reverse(list);
		for(i=0; i<list.length; i++)
			System.out.print(list[i]+",");
		System.out.println();
		System.out.println("*************");
		
		printMax(34, 3, 3, 2, 56.5);
		printMax(new double[]{1,2,3});
		System.out.println("*************");
		
		int[] sort = {1,2,3,4,5};
		System.out.println(java.util.Arrays.binarySearch(sort, 5));
		java.util.Arrays.fill(sort, 7);
		java.util.Arrays.fill(sort, 1, 3, 8);
		System.out.println(java.util.Arrays.toString(sort));
		System.out.println(java.util.Arrays.equals(sort, sort));
	}
	public static void m(int x, int[] y){
		x=3;
		y[0]=3;
	}
	public static void reverse(int[] list){
		int[] myList = new int[list.length];
		for(int i=0; i<list.length; i++)
			myList[i] = list[list.length-1-i];
		for(int i=0; i<myList.length; i++)
			System.out.print(myList[i]+",");
		System.out.println();
		list = myList;
	}
	
	public static void printMax(double... numbers){
		double result = numbers[0];
		for(int i=0; i<numbers.length; i++){
			if(numbers[i] > result)
				result = numbers[i];
		}
		System.out.println("max is "+result);
	}
}